package cn.fzkj.inbox03;

import akka.actor.UntypedAbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;

/**
 * @ author mr
 * @ description
 * @ since 2024/12/2
 */
public class InboxTest extends UntypedAbstractActor {
    private final LoggingAdapter log = Logging.getLogger(getContext().system(), this);

    public enum Msg{
        WORKING, DONE, CLOSE;
    }

    @Override
    public void onReceive(Object o) throws Throwable {
        if(o == Msg.WORKING){
            log.info("i am working.");
        }else if(o == Msg.DONE){
            log.info("i am done");
        }else if(o == Msg.CLOSE){
            log.info("i am close.");
            getSender().tell(Msg.CLOSE, getSelf());//告诉消息发送者我要关闭了。
            getContext().stop(getSelf());//关闭自己
        }else{
            unhandled(o);
        }
    }
}
